use std::env;
use cargo::core::Workspace;
-use cargo::ops::{self, CompileOptions, MessageFormat};
+use cargo::ops::{self, CompileOptions, MessageFormat, Packages};
use cargo::util::{CliResult, Config};
use cargo::util::important_paths::find_root_manifest_for_wd;
Options:
-h, --help Print this message
- -p SPEC, --package SPEC ... Package to check
+ -p SPEC, --package SPEC ... Package(s) to check
+ --all Check all packages in the workspace
-j N, --jobs N Number of parallel jobs, defaults to # of CPUs
--lib Check only this package's library
--bin NAME Check only the specified binary
flag_bench: Vec<String>,
flag_locked: bool,
flag_frozen: bool,
+ flag_all: bool,
}
pub fn execute(options: Options, config: &Config) -> CliResult {
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
let ws = Workspace::new(&root, config)?;
+ let spec = if options.flag_all {
+ Packages::All
+ } else {
+ Packages::Packages(&options.flag_package)
+ };
+
let opts = CompileOptions {
config: config,
jobs: options.flag_jobs,
features: &options.flag_features,
all_features: options.flag_all_features,
no_default_features: options.flag_no_default_features,
- spec: ops::Packages::Packages(&options.flag_package),
+ spec: spec,
mode: ops::CompileMode::Check,
release: options.flag_release,
filter: ops::CompileFilter::new(options.flag_lib,
.arg("--emit=metadata"),
execs().with_status(101));
}
+
+#[test]
+fn check_all() {
+ if !is_nightly() {
+ return
+ }
+ let foo = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+
+ [workspace]
+ [dependencies]
+ b = { path = "b" }
+ "#)
+ .file("src/main.rs", "fn main() {}")
+ .file("examples/a.rs", "fn main() {}")
+ .file("tests/a.rs", "")
+ .file("src/lib.rs", "")
+ .file("b/Cargo.toml", r#"
+ [package]
+ name = "b"
+ version = "0.0.1"
+ authors = []
+ "#)
+ .file("b/src/main.rs", "fn main() {}")
+ .file("b/src/lib.rs", "");
+
+ assert_that(foo.cargo_process("check").arg("--all").arg("-v"),
+ execs().with_status(0)
+ .with_stderr_contains("[..] --crate-name foo src[/]lib.rs [..]")
+ .with_stderr_contains("[..] --crate-name foo src[/]main.rs [..]")
+ .with_stderr_contains("[..] --crate-name b b[/]src[/]lib.rs [..]")
+ .with_stderr_contains("[..] --crate-name b b[/]src[/]main.rs [..]")
+ );
+}